﻿using System;
using System.Web.Security;
using Telerik.Web.UI;

namespace RealEstate
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated && !Roles.IsUserInRole("admin"))
            {
                var radTableTransaction = (RadGrid)LoginView1.FindControl("radTableTransaction");

                var user = Membership.GetUser();
                var clientEntity = new ClientEntities();
                var client = clientEntity.GetByUserId(Guid.Parse(user.ProviderUserKey.ToString()));
                var transactionEntity = new TransactionEntities();

                if (client != null && client.Count > 0)
                {
                    radTableTransaction.DataSource = transactionEntity.GetByClientId(client[0].ClientId);
                    radTableTransaction.DataBind();
                }
            }
        }
    }
}